package com.tedu.lingmaagent.config;


import com.tedu.lingmaagent.store.MongoChatMemoryStore;
import dev.langchain4j.memory.ChatMemory;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MemoryChatAssistantConfig {

    @Autowired
    private MongoChatMemoryStore mongoChatMemoryStore;

    /** 创建聊天记忆对象
     * @return
     * */
    @Bean
    ChatMemory chatMemory(){
        return MessageWindowChatMemory.withMaxMessages(10);
    }
    /** 记忆分离
     * @return
     * */
    /*@Bean
    ChatMemoryProvider chatMemoryProvider(){
        return memoryId-> MessageWindowChatMemory.builder()
                .id(memoryId)
                .maxMessages(10)
                .build();
    }*/

    @Bean
    ChatMemoryProvider chatMemoryProvider(){
        return(memoryId)->MessageWindowChatMemory.builder()
                .id(memoryId)
                .maxMessages(20)
               // .chatMemoryStore(mongoChatMemoryStore)
                .build();
    }
}
